﻿using System;
using AccessControl.Contracts.Models;

namespace AccessControl.Data.Models
{
	public class Event : Model, IEvent
	{
		#region Fields

		bool _Handled;
		DateTime _EventTime;
		ISensor _AssociatedSensor;
		string _Description = string.Empty;
		string _HandlingOperator = string.Empty;

		#endregion

		#region Public Properties

		/// <summary>
		/// Gets or sets a value indicating whether this <see cref="Event"/> is handled.
		/// </summary>
		/// <value>
		///   <c>true</c> if handled; otherwise, <c>false</c>.
		/// </value>
		public bool Handled
		{
			get { return _Handled; }
			set
			{
				if (_Handled != value)
				{
					_Handled = value;
					NotifyPropertyChanged("Handled");
				}
			}
		}

		/// <summary>
		/// Gets or sets the event time.
		/// </summary>
		/// <value>
		/// The event time.
		/// </value>
		public DateTime EventTime
		{
			get { return _EventTime; }
			set
			{
				if (_EventTime != value)
				{
					_EventTime = value;
					NotifyPropertyChanged("EventTime");
				}
			}
		}

		/// <summary>
		/// Gets or sets the associated sensor.
		/// </summary>
		/// <value>
		/// The associated sensor.
		/// </value>
		public ISensor AssociatedSensor
		{
			get { return _AssociatedSensor; }
			set
			{
				if (_AssociatedSensor != value)
				{
					_AssociatedSensor = value;
					NotifyPropertyChanged("AssociatedSensor");
				}
			}
		}

		/// <summary>
		/// Gets or sets the handling operator.
		/// </summary>
		/// <value>
		/// The handling operator.
		/// </value>
		public string HandlingOperator
		{
			get { return _HandlingOperator; }
			set
			{
				if (_HandlingOperator != value)
				{
					_HandlingOperator = value;
					NotifyPropertyChanged("HandlingOperator");
				}
			}
		}

		/// <summary>
		/// Gets or sets the description.
		/// </summary>
		/// <value>
		/// The description.
		/// </value>
		public string Description
		{
			get { return _Description; }
			set
			{
				if (_Description != value)
				{
					_Description = value;
					NotifyPropertyChanged("Description");
				}
			}
		}

		#endregion
	}
}
